package grimbo.goodwinfooty;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TabbedFileReader {
	public Map read(String filename) throws IOException {
		Map m = new HashMap();
		FileReader fr = null;
		try {
			fr = new FileReader(new File(filename));
			BufferedReader r = new BufferedReader(fr);
			String s = r.readLine();
			while (null != s) {
				String[] values = parse(s);
				m.put(values[0], values);
				s = r.readLine();
			}
		} finally {
			if (null != fr) {
				fr.close();
			}
		}
		return m;
	}

	private String[] parse(String s) {
		return s.split("\t");
	}

	public static void main(String[] args) {
		String s = "Alex JONES		0	1	1	3.5	0.00		3.5";
		TabbedFileReader r = new TabbedFileReader();
		String[] values = r.parse(s);
		for (int i = 0; i < values.length; i++) {
			System.out.println(i + " " + values[i]);
		}
	}
}
